import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaintenanceVO, MaintenanceForm, MaintenanceQuery } from '@/api/system/maintenance/types';

/**
 * 查询设备维护保养列表
 * @param query
 * @returns {*}
 */

export const listMaintenance = (query?: MaintenanceQuery): AxiosPromise<MaintenanceVO[]> => {
  return request({
    url: '/system/maintenance/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询设备维护保养详细
 * @param id
 */
export const getMaintenance = (id: string | number): AxiosPromise<MaintenanceVO> => {
  return request({
    url: '/system/maintenance/' + id,
    method: 'get'
  });
};

/**
 * 新增设备维护保养
 * @param data
 */
export const addMaintenance = (data: MaintenanceForm) => {
  return request({
    url: '/system/maintenance',
    method: 'post',
    data: data
  });
};

/**
 * 修改设备维护保养
 * @param data
 */
export const updateMaintenance = (data: MaintenanceForm) => {
  return request({
    url: '/system/maintenance',
    method: 'put',
    data: data
  });
};

/**
 * 删除设备维护保养
 * @param id
 */
export const delMaintenance = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/maintenance/' + id,
    method: 'delete'
  });
};
